import 'package:Smart/res/colors_res.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';
import 'package:Smart/utils/toast_util.dart';
import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  List listData = [
    {"title": "Spring4"},
    {"title": "Spring5"},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // elevation: 0,
        backgroundColor: ColorsRes.color_ffffff,
        title: Text(
          "计划安排",
          style: TextStyle(color: ColorsRes.color_000000),
        ),
      ),
      body: ListView.builder(
        itemCount: listData.length,
        itemBuilder: (BuildContext context, int index) {
          return listItem(listData[index]["title"], onTap: () {
            Toast.showText("计划指定中。。。");
            itemAction(context, index);
          });
        },
      ),
    );
  }

  // ListItem
  Widget listItem(String title, {Function onTap}) {
    return ListTile(
      contentPadding: EdgeInsets.all(0),
      title: Container(
        height: 48,
        // margin: EdgeInsets.all(0),
        // padding: EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: Center(child: Text(title)),
        color: Colors.blue,
      ),
      onTap: onTap,
    );
  }

  // Item事件相应
  void itemAction(BuildContext context, int index) {
    if (index == 0) {
      // PageJumpService.goTo();
    } else if (index == 1) {
      // NavigateRoute.present(context, Routers.devPage,
      //     params: UserInfo("Damon", 30));
    } else if (index == 2) {
      // NavigateRoute.push(context, Routers.devPage,
      //     params: UserInfo("Damon", 30));
    } else {
      // NavigateRoute.push(context, Routers.devPage,
      //     params: {"name": "Simon", "age": 40});
    }
  }
}

class UserInfo {
  var age;

  var name;
  Object obj = {"aa": "111", "bbb": "222"};

  UserInfo(this.name, this.age);
}
